
#ifndef _MEMBER_BBODY_H_
#define _MEMBER_BBODY_H_

#include <BRestraint>
#include "IOverlapPair.h"

#define body_member(body)		((member_BBody*)((BBody*)body)->_ptr)

namespace BWE
{
	class member_BBody
	{
	public:
		member_BBody(BBody* body);
		~member_BBody();

		void updateInertia();
		void updateSolverData(BReal timeStep);
		void updateDeactivating(BReal timeStep);
		BVector angularComponent(const BVector& vector);

	public:
		BBody*				boss;
		BBody::State		state;
		bool				kinematic;
		bool				continuous;

		BReal				mass;
		BVector				gravity;
		BReal				restitution;
		BReal				friction;
		BReal				rollingFriction;

		BVector				force;
		BVector				torque;
		BVector				pushVelocity;
		BVector				turnVelocity;
		BVector				linearVelocity;
		BVector				angularVelocity;

		BReal				deactivatedTime;
		BReal				deactivatingTime;
		BReal				linearThreshold;
		BReal				angularThreshold;

		bool				dirty;
		BReal				invMass;
		BVector				inertia;
		BVector				invInertia;
		BMatrix				predictedMatrix;
		BHolder<BodyProxy>	bodyProxy;
		SolverData			solverData;
		BSet<BRestraint*>	restraints;
	};
}

#endif